package com.nowcoder.community.controller;

import com.nowcoder.community.service.AlphaService;
import com.nowcoder.community.util.GenerateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/alpha")
public class AlphaController {

    @Autowired
    private AlphaService alphaService;

    @RequestMapping("/hello")
    public String sayHello() {
        return "Hello Spring Boot.";
    }

    @RequestMapping("/data")
    public String getData() {
        return alphaService.find();
    }

    //测试 ajax
    @RequestMapping(value = "/ajax",method = RequestMethod.POST)
    @ResponseBody
    public String jsonRequest(String name,int age){
        System.out.println(name + ":" + age);
        return GenerateUtil.getJsonString(0,"ok");
    }

}
